#include "ServerCommandInterpreter.h"
#include "const.h"

/* TODO: Lista de comandos server:
 * 			GET-FILE-LIST (todos los archivos del repo)
 * 			POST #nombreArchivo (el cliente le manda esto al server para que actualice su repo
 *			LOGOUT (cli -> srv)
 *
 */


ServerCommandInterpreter::ServerCommandInterpreter(){
	comandos[GETFILELIST] = new GetFilesCommand();
	comandos[GETFILE] = new GetFileCommand();
	comandos[TRYUPDATEUP] = new TryUpdateUpFileCommand();
	comandos[TRYUPDATEDOWN] = new TryUpdateDownFileCommand();
	comandos[UPDATEFILE] = new UpdateFileCommand();
	comandos[UPDATEEMISOR] = new UpdateFileEmisorCommand();
	comandos[UPDATERECEPTOR] = new UpdateFileReceptorCommand();
	comandos[UPDATERECEPTOR2] = new UpdateFileReceptor2Command();
	comandos[UPDATEOK] = new UpdateFileFinishedCommand();
	comandos[ERASEFILE] = new EraseFileCommand();
	comandos[UPLOADFILE] = new UploadFileCommand();
	comandos[LOGOUT] = new LogoutCommand();
}

ServerCommandInterpreter::~ServerCommandInterpreter(){
	delete(comandos[GETFILELIST]);
	delete(comandos[GETFILE]);
	delete(comandos[TRYUPDATEUP]);
	delete(comandos[TRYUPDATEDOWN]);
	delete(comandos[UPDATEFILE]);
	delete(comandos[UPDATEEMISOR]);
	delete(comandos[UPDATERECEPTOR]);
	delete(comandos[UPDATERECEPTOR2]);
	delete(comandos[UPDATEOK]);
	delete(comandos[ERASEFILE]);
	delete(comandos[UPLOADFILE]);
	delete(comandos[LOGOUT]);
}

ServerCommand* ServerCommandInterpreter::operator[](std::string &s){
	return comandos.at(s);
}
